#!/bin/sh

. /etc/utils.sh

case "$1" in
  start)
    # TODO(showarth): remove check for diag=1.
    if [ "$(kernopt diag)" = 1 ] || contains "$(kernopt diag)" "diags"; then
      echo "diag is set: running diags on boot."
      diags &
    else
      echo "diag is not set: skipping."
    fi
    ;;
  stop)
    pkillwait -x diags
    ;;
  restart)
    $0 stop; $0 start
    ;;
  *)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
esac
